|
1
|
|
|
import chai from 'chai' |
|
2
|
|
|
import path from 'path' |
|
3
|
|
|
import sinonChai from'sinon-chai' |
|
4
|
|
|
chai.use(sinonChai) |
|
5
|
|
|
import sinon from 'sinon' |
|
6
|
|
|
import {config} from '../src/cli' |
|
7
|
|
|
config.set({root: path.join(__dirname,'fixtures')}) |
|
8
|
|
|
|
|
9
|
|
|
import { |
|
10
|
|
|
cmsEditor, |
|
11
|
|
|
abeExtend |
|
12
|
|
|
} from '../src/cli' |
|
13
|
|
|
|
|
14
|
|
|
import data from './fixtures/editor/index' |
|
15
|
|
|
|
|
16
|
|
|
describe('Editor', function() { |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* cmsEditor.printInput |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
it('cmsEditor.printInput()', function() { |
|
23
|
|
|
var val = data.text; |
|
24
|
|
|
this.sinon = sinon.sandbox.create(); |
|
25
|
|
|
this.sinon.stub(abeExtend.hooks.instance, 'trigger', function(param, html){ |
|
26
|
|
|
return (param === 'beforeEditorInput') ? val : html; |
|
27
|
|
|
}) |
|
28
|
|
|
|
|
29
|
|
|
var result = cmsEditor.printInput(val, {}) |
|
30
|
|
|
chai.expect(result).to.be.a('string') |
|
31
|
|
|
var value = result.match(/value="[a-zA-Z0-9-]*"/ig)[0] |
|
32
|
|
|
chai.expect(value).to.equal('value="val2"') |
|
33
|
|
|
var reload = result.match(/reload="[a-zA-Z0-9-]*"/ig)[0] |
|
34
|
|
|
chai.expect(reload).to.equal('reload="val3"') |
|
35
|
|
|
var tabIndex = result.match(/tabIndex="[a-zA-Z0-9-]*"/ig)[0] |
|
36
|
|
|
chai.expect(tabIndex).to.equal('tabIndex="val4"') |
|
37
|
|
|
var dataRequired = result.match(/data-required="[a-zA-Z0-9-]*"/ig)[0] |
|
38
|
|
|
chai.expect(dataRequired).to.equal('data-required="val5"') |
|
39
|
|
|
var dataDisplay = result.match(/data-display="[a-zA-Z0-9-]*"/ig)[0] |
|
40
|
|
|
chai.expect(dataDisplay).to.equal('data-display="val6"') |
|
41
|
|
|
var dataVisible = result.match(/data-visible="[a-zA-Z0-9-]*"/ig)[0] |
|
42
|
|
|
chai.expect(dataVisible).to.equal('data-visible="val7"') |
|
43
|
|
|
var dataAutocomplete = result.match(/data-autocomplete="[a-zA-Z0-9-]*"/ig)[0] |
|
44
|
|
|
chai.expect(dataAutocomplete).to.equal('data-autocomplete="val8"') |
|
45
|
|
|
var placeholder = result.match(/placeholder="[a-zA-Z0-9-]*"/ig)[0] |
|
46
|
|
|
chai.expect(placeholder).to.equal('placeholder="val9"') |
|
47
|
|
|
|
|
48
|
|
|
this.sinon.restore() |
|
49
|
|
|
}); |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* cmsEditor.folders |
|
53
|
|
|
* |
|
54
|
|
|
*/ |
|
55
|
|
|
it('cmsEditor.folders()', function() { |
|
56
|
|
|
var result = cmsEditor.folders([{path: ''}], 1, null, {'level-1': 'my wording'}) |
|
57
|
|
|
var wordingExist = result.indexOf('my wording') |
|
58
|
|
|
chai.expect(result).to.be.a('string') |
|
59
|
|
|
chai.expect(wordingExist).to.equal(110) |
|
60
|
|
|
}); |
|
61
|
|
|
|
|
62
|
|
|
}); |
|
63
|
|
|
|